﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace DuJianliang.ApplicationPlatform
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //InitFlowItems();

                if (Common.CurrentInfo.Instance.CurrentUser != null)
                {
                    hidCurrentInfo.Value = "当前用户: " + Common.CurrentInfo.Instance.CurrentUser.UserName;
                }
                else
                {
                    Response.Redirect("login.aspx");
                }                
            }
        }

//        private void InitFlowItems()
//        {
//            string getFlowItems = @"SELECT A.FlowID, A.FlowName, A.FormPath, A.TableName, B.StepID FROM dbo.FlowMain A LEFT JOIN 
//                                    (SELECT FlowID, StepID FROM dbo.FlowStep 
//                                    WHERE StepID IN (SELECT StepID FROM dbo.FlowStepRelation WHERE ParentID IS NULL)) B ON A.FlowID = B.FlowID";

//            Database database = DatabaseFactory.CreateDatabase();
//            DbCommand dbCommand = database.GetSqlStringCommand(getFlowItems);
//            DataTable dataTable = database.ExecuteDataSet(dbCommand).Tables[0];

//            Repeater1.DataSource = dataTable;
//            Repeater1.DataBind();
//        }


        protected void tvFunction_SelectedNodeChanged(object sender, EventArgs e)
        {
            if (tvFunction.SelectedValue.Equals("退出"))
            {
                Common.CurrentInfo.Instance.CurrentUser = null;
                Response.Redirect("login.aspx");
            }
        }
    }
}